 var app = getApp()
Page({
	data: {
		count: "0",
		amount: "00.00",
		logoUrl: "../../images/user_pic.png",
    name:"GK商家工作台",
    buttonHide: false,
    loginUserName: ""
	},
  onLoad: function () {
    this.logincheck()
  },
	oeoneTap: function () {
    var _that = this
    var session_id = wx.getStorageSync(app.globalData.sessionId)
    if (session_id == "" || session_id == null) {
      wx.navigateTo({
        url: '../logIn/logIn'
      })
    }
    else {
      wx.navigateTo({
        url: '../list/list'
      })
    }
	},
	buttonTap: function () {
    wx.navigateTo({
			url: '../logIn/logIn',
		})
	},
  logincheck:function(){
    var _that = this
    var session_id = wx.getStorageSync(app.globalData.sessionId)
    if (session_id == "" || session_id == null){
      _that.setData({
        buttonHide: false
      })
    }
    else{
      _that.setData({
         buttonHide:true
      })
    }
  },
	bhimageTap: function () {
    var _that = this
    var session_id = wx.getStorageSync(app.globalData.sessionId)
    if (session_id == "" || session_id == null) {
      wx.navigateTo({
        url: '../logIn/logIn'
      })
    }
    else {
      wx.navigateTo({
        url: '../personalCenter/personalCenter'
      })
    }
    
  }, 
  ServiceTap: function () {
    wx.makePhoneCall({
      phoneNumber: '4001000850'
    })
  },
	onShow: function (res) {
    this.logincheck()
		var that = this;
		wx.request({
      url: app.globalData.apiUrl +'/mobileOfficing/api/workBench',
			method: 'POST',
			header: {
        'sessionId': wx.getStorageSync(app.globalData.sessionId)
			},
			success: function (res) {
        if(res.data.result){
          that.setData({
            loginUserName: res.data.data.user.name,
            name: res.data.data.merchant.name,
            count: res.data.data.count,
            amount: res.data.data.amount,
            logoUrl: res.data.data.merchant.logoUrl
          })
        }else{
          that.setData({
            buttonHide: false
          })
        }
			}
		})
	}
})



